package me.zhengjie.tool;


import java.io.BufferedReader;
import java.sql.Clob;

public class ClobUtil {


    /**
     * CLob字段转为字符串
     *
     * @param clob
     * @return
     */
    public static String clobToString(Clob clob) {
        if (ValidateUtil.isEmpty(clob)) {
            return "";
        }
        String reString = "";
        StringBuffer sb = new StringBuffer();
        try {
            java.io.Reader is = clob.getCharacterStream();// 得到流
            BufferedReader br = new BufferedReader(is);
            String s = br.readLine();
            while (s != null) {// 执行循环将字符串全部取出付值给StringBuffer由StringBuffer转成STRING
                sb.append(s);
                s = br.readLine();
            }
        } catch (Exception e) {
            throw new IllegalArgumentException(e.getMessage());
        }
        reString = sb.toString();
        return reString;
    }

}
